<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>sampleFile - OpenGrok cross reference for /sampleFile</title></head><body>
<script type="text/javascript">/* <![CDATA[ */
function get_sym_list(){return [["Namespace","xn",[["::sqawk",25]]]];} /* ]]> */</script><a class="l" name="1" href="#1">1</a><span class="c"># Copyright (c) 2015, 2016, 2017 dbohdan</span>
<a class="l" name="2" href="#2">2</a><span class="c">#</span>
<a class="l" name="3" href="#3">3</a><span class="c"># Permission is hereby granted, free of charge, to any person obtaining a copy</span>
<a class="l" name="4" href="#4">4</a><span class="c"># of this software and associated documentation files (the &quot;Software&quot;), to deal</span>
<a class="l" name="5" href="#5">5</a><span class="c"># in the Software without restriction, including without limitation the rights</span>
<a class="l" name="6" href="#6">6</a><span class="c"># to use, copy, modify, merge, publish, distribute, sublicense, <a href="/source/s?path=and/">and</a>/<a href="/source/s?path=and/or">or</a> sell</span>
<a class="l" name="7" href="#7">7</a><span class="c"># copies of the Software, and to permit persons to whom the Software is</span>
<a class="l" name="8" href="#8">8</a><span class="c"># furnished to do so, subject to the following conditions:</span>
<a class="l" name="9" href="#9">9</a><span class="c">#</span>
<a class="hl" name="10" href="#10">10</a><span class="c"># The above copyright notice and this permission notice shall be included in</span>
<a class="l" name="11" href="#11">11</a><span class="c"># all copies or substantial portions of the Software.</span>
<a class="l" name="12" href="#12">12</a><span class="c">#</span>
<a class="l" name="13" href="#13">13</a><span class="c"># THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR</span>
<a class="l" name="14" href="#14">14</a><span class="c"># IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,</span>
<a class="l" name="15" href="#15">15</a><span class="c"># FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE</span>
<a class="l" name="16" href="#16">16</a><span class="c"># AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER</span>
<a class="l" name="17" href="#17">17</a><span class="c"># LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,</span>
<a class="l" name="18" href="#18">18</a><span class="c"># OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN</span>
<a class="l" name="19" href="#19">19</a><span class="c"># THE SOFTWARE.</span>
<a class="hl" name="20" href="#20">20</a>
<a class="l" name="21" href="#21">21</a><span class="c"># Sqawk, an SQL Awk.</span>
<a class="l" name="22" href="#22">22</a><span class="c"># Copyright (C) 2015, 2016, 2017 dbohdan</span>
<a class="l" name="23" href="#23">23</a><span class="c"># License: MIT</span>
<a class="l" name="24" href="#24">24</a>
<a class="l" name="25" href="#25">25</a><b>namespace</b> <b>eval</b> <a class="xn" name="::sqawk"/><a href="/source/s?refs=%5C%3A%5C%3Asqawk" class="xn intelliWindow-symbol" data-definition-place="def">::sqawk</a> {}
<a class="l" name="26" href="#26">26</a>
<a class="l" name="27" href="#27">27</a><span class="c"># Performs SQL queries on files and channels.</span>
<a class="l" name="28" href="#28">28</a><a href="/source/s?defs=%5C%3A%5C%3Asnit%5C%3A%5C%3Atype" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::snit::type</a> <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Asqawk" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::sqawk</a> {
<a class="l" name="29" href="#29">29</a>    <span class="c"># Internal object state.</span>
<a class="hl" name="30" href="#30">30</a>    <b>variable</b> <a href="/source/s?defs=tables" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tables</a> {}
<a class="l" name="31" href="#31">31</a>    <b>variable</b> <a href="/source/s?defs=defaultTableNames" class="intelliWindow-symbol" data-definition-place="undefined-in-file">defaultTableNames</a> [<b>split</b> <a href="/source/s?defs=abcdefghijklmnopqrstuvwxyz" class="intelliWindow-symbol" data-definition-place="undefined-in-file">abcdefghijklmnopqrstuvwxyz</a> <span class="s">&quot;&quot;</span>]
<a class="l" name="32" href="#32">32</a>    <b>variable</b> <a href="/source/s?defs=formatToParser" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatToParser</a>
<a class="l" name="33" href="#33">33</a>    <b>variable</b> <a href="/source/s?defs=formatToSerializer" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatToSerializer</a>
<a class="l" name="34" href="#34">34</a>
<a class="l" name="35" href="#35">35</a>    <span class="c"># Options.</span>
<a class="l" name="36" href="#36">36</a>    <b>option</b> -<a href="/source/s?defs=database" class="intelliWindow-symbol" data-definition-place="undefined-in-file">database</a>
<a class="l" name="37" href="#37">37</a>    <b>option</b> -<a href="/source/s?defs=ofs" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ofs</a>
<a class="l" name="38" href="#38">38</a>    <b>option</b> -<a href="/source/s?defs=ors" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ors</a>
<a class="l" name="39" href="#39">39</a>
<a class="hl" name="40" href="#40">40</a>    <b>option</b> -<a href="/source/s?defs=destroytables" class="intelliWindow-symbol" data-definition-place="undefined-in-file">destroytables</a> -<a href="/source/s?defs=default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">default</a> <a href="/source/s?defs=true" class="intelliWindow-symbol" data-definition-place="undefined-in-file">true</a>
<a class="l" name="41" href="#41">41</a>    <b>option</b> -<a href="/source/s?defs=outputformat" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputformat</a> -<a href="/source/s?defs=default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">default</a> <a href="/source/s?defs=awk" class="intelliWindow-symbol" data-definition-place="undefined-in-file">awk</a>
<a class="l" name="42" href="#42">42</a>    <b>option</b> -<a href="/source/s?defs=parsers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">parsers</a> -<a href="/source/s?defs=default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">default</a> {} -<a href="/source/s?defs=configuremethod" class="intelliWindow-symbol" data-definition-place="undefined-in-file">configuremethod</a> <a href="/source/s?defs=Set%5C-and%5C-update%5C-format%5C-list" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Set-and-update-format-list</a>
<a class="l" name="43" href="#43">43</a>    <b>option</b> -<a href="/source/s?defs=serializers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">serializers</a> -<a href="/source/s?defs=default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">default</a> {} -<a href="/source/s?defs=configuremethod" class="intelliWindow-symbol" data-definition-place="undefined-in-file">configuremethod</a> <a href="/source/s?defs=Set%5C-and%5C-update%5C-format%5C-list" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Set-and-update-format-list</a>
<a class="l" name="44" href="#44">44</a>
<a class="l" name="45" href="#45">45</a>    <span class="c"># Methods.</span>
<a class="l" name="46" href="#46">46</a>    <a href="/source/s?defs=constructor" class="intelliWindow-symbol" data-definition-place="undefined-in-file">constructor</a> {} {
<a class="l" name="47" href="#47">47</a>        <span class="c"># Register parsers and serializers.</span>
<a class="l" name="48" href="#48">48</a>        $<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=configure" class="intelliWindow-symbol" data-definition-place="undefined-in-file">configure</a> -<a href="/source/s?defs=parsers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">parsers</a> [<b>namespace</b> <a href="/source/s?defs=children" class="intelliWindow-symbol" data-definition-place="undefined-in-file">children</a> <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Aparsers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::parsers</a>]
<a class="l" name="49" href="#49">49</a>        $<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=configure" class="intelliWindow-symbol" data-definition-place="undefined-in-file">configure</a> -<a href="/source/s?defs=serializers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">serializers</a> [<b>namespace</b> <a href="/source/s?defs=children" class="intelliWindow-symbol" data-definition-place="undefined-in-file">children</a> <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Aserializers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::serializers</a>]
<a class="hl" name="50" href="#50">50</a>    }
<a class="l" name="51" href="#51">51</a>
<a class="l" name="52" href="#52">52</a>    <a href="/source/s?defs=destructor" class="intelliWindow-symbol" data-definition-place="undefined-in-file">destructor</a> {
<a class="l" name="53" href="#53">53</a>        <b>if</b> {[$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=cget" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cget</a> -<a href="/source/s?defs=destroytables" class="intelliWindow-symbol" data-definition-place="undefined-in-file">destroytables</a>]} {
<a class="l" name="54" href="#54">54</a>            <b>dict</b> <b>for</b> {<a href="/source/s?defs=_" class="intelliWindow-symbol" data-definition-place="undefined-in-file">_</a> <a href="/source/s?defs=tableObj" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tableObj</a>} $<a href="/source/s?defs=tables" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tables</a> {
<a class="l" name="55" href="#55">55</a>                $<a href="/source/s?defs=tableObj" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tableObj</a> <b>destroy</b>
<a class="l" name="56" href="#56">56</a>            }
<a class="l" name="57" href="#57">57</a>        }
<a class="l" name="58" href="#58">58</a>    }
<a class="l" name="59" href="#59">59</a>
<a class="hl" name="60" href="#60">60</a>    <span class="c"># Update the related format dictionary when the parser or the serializer</span>
<a class="l" name="61" href="#61">61</a>    <span class="c"># list option is set.</span>
<a class="l" name="62" href="#62">62</a>    <a href="/source/s?defs=method" class="intelliWindow-symbol" data-definition-place="undefined-in-file">method</a> <a href="/source/s?defs=Set%5C-and%5C-update%5C-format%5C-list" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Set-and-update-format-list</a> {<b>option</b> <a href="/source/s?defs=value" class="intelliWindow-symbol" data-definition-place="undefined-in-file">value</a>} {
<a class="l" name="63" href="#63">63</a>        <b>set</b> <a href="/source/s?defs=optToDict" class="intelliWindow-symbol" data-definition-place="undefined-in-file">optToDict</a> {
<a class="l" name="64" href="#64">64</a>            -<a href="/source/s?defs=parsers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">parsers</a> <a href="/source/s?defs=formatToParser" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatToParser</a>
<a class="l" name="65" href="#65">65</a>            -<a href="/source/s?defs=serializers" class="intelliWindow-symbol" data-definition-place="undefined-in-file">serializers</a> <a href="/source/s?defs=formatToSerializer" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatToSerializer</a>
<a class="l" name="66" href="#66">66</a>        }
<a class="l" name="67" href="#67">67</a>        <b>set</b> <a href="/source/s?defs=possibleOpts" class="intelliWindow-symbol" data-definition-place="undefined-in-file">possibleOpts</a> [<b>dict</b> <a href="/source/s?defs=keys" class="intelliWindow-symbol" data-definition-place="undefined-in-file">keys</a> $<a href="/source/s?defs=optToDict" class="intelliWindow-symbol" data-definition-place="undefined-in-file">optToDict</a>]
<a class="l" name="68" href="#68">68</a>        <b>if</b> {$<b>option</b> <a href="/source/s?defs=ni" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ni</a> $<a href="/source/s?defs=possibleOpts" class="intelliWindow-symbol" data-definition-place="undefined-in-file">possibleOpts</a>} {
<a class="l" name="69" href="#69">69</a>            <b>error</b> <span class="s">&quot;Set-and-update-format-list can&apos;t set the option \&quot;$<b>option</b>\&quot;&quot;</span>
<a class="hl" name="70" href="#70">70</a>        }
<a class="l" name="71" href="#71">71</a>        <b>set</b> <b>options</b>($<b>option</b>) $<a href="/source/s?defs=value" class="intelliWindow-symbol" data-definition-place="undefined-in-file">value</a>
<a class="l" name="72" href="#72">72</a>
<a class="l" name="73" href="#73">73</a>        <b>set</b> <a href="/source/s?defs=dictName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">dictName</a> [<b>dict</b> <a href="/source/s?defs=get" class="intelliWindow-symbol" data-definition-place="undefined-in-file">get</a> $<a href="/source/s?defs=optToDict" class="intelliWindow-symbol" data-definition-place="undefined-in-file">optToDict</a> $<b>option</b>]
<a class="l" name="74" href="#74">74</a>        <b>set</b> $<a href="/source/s?defs=dictName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">dictName</a> {}
<a class="l" name="75" href="#75">75</a>        <span class="c"># For each <a href="/source/s?path=parser/">parser</a>/<a href="/source/s?path=parser/serializer">serializer</a>...</span>
<a class="l" name="76" href="#76">76</a>        <b>foreach</b> <a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a> $<a href="/source/s?defs=value" class="intelliWindow-symbol" data-definition-place="undefined-in-file">value</a> {
<a class="l" name="77" href="#77">77</a>            <b>foreach</b> <b>format</b> [<b>set</b> ${<a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a>}<a href="/source/s?defs=%5C%3A%5C%3Aformats" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::formats</a>] {
<a class="l" name="78" href="#78">78</a>                <b>dict</b> <b>set</b> $<a href="/source/s?defs=dictName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">dictName</a> $<b>format</b> $<a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a>
<a class="l" name="79" href="#79">79</a>            }
<a class="hl" name="80" href="#80">80</a>        }
<a class="l" name="81" href="#81">81</a>    }
<a class="l" name="82" href="#82">82</a>
<a class="l" name="83" href="#83">83</a>    <span class="c"># Parse $data from $format into a list of rows.</span>
<a class="l" name="84" href="#84">84</a>    <a href="/source/s?defs=method" class="intelliWindow-symbol" data-definition-place="undefined-in-file">method</a> <a href="/source/s?defs=Parse" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Parse</a> {<b>format</b> <a href="/source/s?defs=data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">data</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a>} {
<a class="l" name="85" href="#85">85</a>        <b>set</b> <b>error</b> [<b>catch</b> {
<a class="l" name="86" href="#86">86</a>            <b>set</b> <a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a> [<b>dict</b> <a href="/source/s?defs=get" class="intelliWindow-symbol" data-definition-place="undefined-in-file">get</a> $<a href="/source/s?defs=formatToParser" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatToParser</a> $<b>format</b>]
<a class="l" name="87" href="#87">87</a>        }]
<a class="l" name="88" href="#88">88</a>        <b>if</b> {$<b>error</b>} {
<a class="l" name="89" href="#89">89</a>            <b>error</b> <span class="s">&quot;unknown input format: \&quot;$<b>format</b>\&quot;&quot;</span>
<a class="hl" name="90" href="#90">90</a>        }
<a class="l" name="91" href="#91">91</a>        <b>set</b> <a href="/source/s?defs=parseOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">parseOptions</a> [<b>set</b> ${<a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a>}<a href="/source/s?defs=%5C%3A%5C%3Aoptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::options</a>]
<a class="l" name="92" href="#92">92</a>        <b>return</b> [${<a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a>}<a href="/source/s?defs=%5C%3A%5C%3Aparse" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::parse</a> $<a href="/source/s?defs=data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">data</a> \
<a class="l" name="93" href="#93">93</a>                [<a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Aoverride%5C-keys" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::override-keys</a> $<a href="/source/s?defs=parseOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">parseOptions</a> $<a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a>]]
<a class="l" name="94" href="#94">94</a>    }
<a class="l" name="95" href="#95">95</a>
<a class="l" name="96" href="#96">96</a>    <span class="c"># Serialize a list of rows into text in the format $format.</span>
<a class="l" name="97" href="#97">97</a>    <a href="/source/s?defs=method" class="intelliWindow-symbol" data-definition-place="undefined-in-file">method</a> <a href="/source/s?defs=Serialize" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Serialize</a> {<b>format</b> <a href="/source/s?defs=data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">data</a> <a href="/source/s?defs=sqawkOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">sqawkOptions</a>} {
<a class="l" name="98" href="#98">98</a>        <span class="c"># Parse $format.</span>
<a class="l" name="99" href="#99">99</a>        <b>set</b> <a href="/source/s?defs=splitFormat" class="intelliWindow-symbol" data-definition-place="undefined-in-file">splitFormat</a> [<b>split</b> $<b>format</b> ,]
<a class="hl" name="100" href="#100">100</a>        <b>set</b> <a href="/source/s?defs=formatName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatName</a> [<b>lindex</b> $<a href="/source/s?defs=splitFormat" class="intelliWindow-symbol" data-definition-place="undefined-in-file">splitFormat</a> <span class="n">0</span>]
<a class="l" name="101" href="#101">101</a>        <b>set</b> <a href="/source/s?defs=formatOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatOptions</a> {}
<a class="l" name="102" href="#102">102</a>        <b>foreach</b> <b>option</b> [<b>lrange</b> $<a href="/source/s?defs=splitFormat" class="intelliWindow-symbol" data-definition-place="undefined-in-file">splitFormat</a> <span class="n">1</span> <a href="/source/s?defs=end" class="intelliWindow-symbol" data-definition-place="undefined-in-file">end</a>] {
<a class="l" name="103" href="#103">103</a>            <b>lassign</b> [<b>split</b> $<b>option</b> =] <a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a> <a href="/source/s?defs=value" class="intelliWindow-symbol" data-definition-place="undefined-in-file">value</a>
<a class="l" name="104" href="#104">104</a>            <b>lappend</b> <a href="/source/s?defs=formatOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatOptions</a> $<a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a> $<a href="/source/s?defs=value" class="intelliWindow-symbol" data-definition-place="undefined-in-file">value</a>
<a class="l" name="105" href="#105">105</a>        }
<a class="l" name="106" href="#106">106</a>        <b>set</b> <b>error</b> [<b>catch</b> {
<a class="l" name="107" href="#107">107</a>            <b>set</b> <a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a> [<b>dict</b> <a href="/source/s?defs=get" class="intelliWindow-symbol" data-definition-place="undefined-in-file">get</a> $<a href="/source/s?defs=formatToSerializer" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatToSerializer</a> $<a href="/source/s?defs=formatName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatName</a>]
<a class="l" name="108" href="#108">108</a>        }]
<a class="l" name="109" href="#109">109</a>        <b>if</b> {$<b>error</b>} {
<a class="hl" name="110" href="#110">110</a>            <b>error</b> <span class="s">&quot;unknown output format: \&quot;$<a href="/source/s?defs=formatName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatName</a>\&quot;&quot;</span>
<a class="l" name="111" href="#111">111</a>        }
<a class="l" name="112" href="#112">112</a>
<a class="l" name="113" href="#113">113</a>        <span class="c"># Get the dict containing the options the serializer accepts with their</span>
<a class="l" name="114" href="#114">114</a>        <span class="c"># default values.</span>
<a class="l" name="115" href="#115">115</a>        <b>set</b> <a href="/source/s?defs=so" class="intelliWindow-symbol" data-definition-place="undefined-in-file">so</a> [<b>set</b> ${<a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a>}<a href="/source/s?defs=%5C%3A%5C%3Aoptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::options</a>]
<a class="l" name="116" href="#116">116</a>        <span class="c"># Set the two main options for the &quot;awk&quot; serializer. &quot;awk&quot; is a special</span>
<a class="l" name="117" href="#117">117</a>        <span class="c"># case: its options are set based on separate command line arguments</span>
<a class="l" name="118" href="#118">118</a>        <span class="c"># whose values are passed to us in $sqawkOptions.</span>
<a class="l" name="119" href="#119">119</a>        <b>if</b> {$<a href="/source/s?defs=formatName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatName</a> <a href="/source/s?defs=eq" class="intelliWindow-symbol" data-definition-place="undefined-in-file">eq</a> {<a href="/source/s?defs=awk" class="intelliWindow-symbol" data-definition-place="undefined-in-file">awk</a>}} {
<a class="hl" name="120" href="#120">120</a>            <b>if</b> {[<b>dict</b> <a href="/source/s?defs=exists" class="intelliWindow-symbol" data-definition-place="undefined-in-file">exists</a> $<a href="/source/s?defs=formatOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatOptions</a> <a href="/source/s?defs=ofs" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ofs</a>]} {
<a class="l" name="121" href="#121">121</a>                <b>error</b> {<a href="/source/s?defs=to" class="intelliWindow-symbol" data-definition-place="undefined-in-file">to</a> <b>set</b> <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <a href="/source/s?defs=field" class="intelliWindow-symbol" data-definition-place="undefined-in-file">field</a> <a href="/source/s?defs=separator" class="intelliWindow-symbol" data-definition-place="undefined-in-file">separator</a> <b>for</b> <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <span class="s">&quot;awk&quot;</span> <a href="/source/s?defs=output" class="intelliWindow-symbol" data-definition-place="undefined-in-file">output</a> <b>format</b>\
<a class="l" name="122" href="#122">122</a>                        <a href="/source/s?defs=please" class="intelliWindow-symbol" data-definition-place="undefined-in-file">please</a> <a href="/source/s?defs=use" class="intelliWindow-symbol" data-definition-place="undefined-in-file">use</a> <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <a href="/source/s?defs=command" class="intelliWindow-symbol" data-definition-place="undefined-in-file">command</a> <a href="/source/s?defs=line" class="intelliWindow-symbol" data-definition-place="undefined-in-file">line</a> <b>option</b> <span class="s">&quot;-OFS&quot;</span> <a href="/source/s?defs=instead" class="intelliWindow-symbol" data-definition-place="undefined-in-file">instead</a> <a href="/source/s?defs=of" class="intelliWindow-symbol" data-definition-place="undefined-in-file">of</a>\
<a class="l" name="123" href="#123">123</a>                        <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <b>format</b> <b>option</b> <span class="s">&quot;ofs&quot;</span>}
<a class="l" name="124" href="#124">124</a>            }
<a class="l" name="125" href="#125">125</a>            <b>if</b> {[<b>dict</b> <a href="/source/s?defs=exists" class="intelliWindow-symbol" data-definition-place="undefined-in-file">exists</a> $<a href="/source/s?defs=formatOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatOptions</a> <a href="/source/s?defs=ors" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ors</a>]} {
<a class="l" name="126" href="#126">126</a>                <b>error</b> {<a href="/source/s?defs=to" class="intelliWindow-symbol" data-definition-place="undefined-in-file">to</a> <b>set</b> <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <a href="/source/s?defs=record" class="intelliWindow-symbol" data-definition-place="undefined-in-file">record</a> <a href="/source/s?defs=separator" class="intelliWindow-symbol" data-definition-place="undefined-in-file">separator</a> <b>for</b> <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <span class="s">&quot;awk&quot;</span> <a href="/source/s?defs=output" class="intelliWindow-symbol" data-definition-place="undefined-in-file">output</a> <b>format</b>\
<a class="l" name="127" href="#127">127</a>                        <a href="/source/s?defs=please" class="intelliWindow-symbol" data-definition-place="undefined-in-file">please</a> <a href="/source/s?defs=use" class="intelliWindow-symbol" data-definition-place="undefined-in-file">use</a> <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <a href="/source/s?defs=command" class="intelliWindow-symbol" data-definition-place="undefined-in-file">command</a> <a href="/source/s?defs=line" class="intelliWindow-symbol" data-definition-place="undefined-in-file">line</a> <b>option</b> <span class="s">&quot;-OFS&quot;</span> <a href="/source/s?defs=instead" class="intelliWindow-symbol" data-definition-place="undefined-in-file">instead</a> <a href="/source/s?defs=of" class="intelliWindow-symbol" data-definition-place="undefined-in-file">of</a>\
<a class="l" name="128" href="#128">128</a>                        <a href="/source/s?defs=the" class="intelliWindow-symbol" data-definition-place="undefined-in-file">the</a> <b>format</b> <b>option</b> <span class="s">&quot;ofs&quot;</span>}
<a class="l" name="129" href="#129">129</a>            }
<a class="hl" name="130" href="#130">130</a>            <b>dict</b> <b>set</b> <a href="/source/s?defs=so" class="intelliWindow-symbol" data-definition-place="undefined-in-file">so</a> <a href="/source/s?defs=ofs" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ofs</a> [<b>dict</b> <a href="/source/s?defs=get" class="intelliWindow-symbol" data-definition-place="undefined-in-file">get</a> $<a href="/source/s?defs=sqawkOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">sqawkOptions</a> -<a href="/source/s?defs=ofs" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ofs</a>]
<a class="l" name="131" href="#131">131</a>            <b>dict</b> <b>set</b> <a href="/source/s?defs=so" class="intelliWindow-symbol" data-definition-place="undefined-in-file">so</a> <a href="/source/s?defs=ors" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ors</a> [<b>dict</b> <a href="/source/s?defs=get" class="intelliWindow-symbol" data-definition-place="undefined-in-file">get</a> $<a href="/source/s?defs=sqawkOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">sqawkOptions</a> -<a href="/source/s?defs=ors" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ors</a>]
<a class="l" name="132" href="#132">132</a>        }
<a class="l" name="133" href="#133">133</a>        <span class="c"># Check if all the serializer options we have been given in $format are</span>
<a class="l" name="134" href="#134">134</a>        <span class="c"># valid. Replace the default values with the actual values.</span>
<a class="l" name="135" href="#135">135</a>        <b>foreach</b> {<a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a> <a href="/source/s?defs=value" class="intelliWindow-symbol" data-definition-place="undefined-in-file">value</a>} $<a href="/source/s?defs=formatOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatOptions</a> {
<a class="l" name="136" href="#136">136</a>            <b>if</b> {[<b>dict</b> <a href="/source/s?defs=exists" class="intelliWindow-symbol" data-definition-place="undefined-in-file">exists</a> $<a href="/source/s?defs=so" class="intelliWindow-symbol" data-definition-place="undefined-in-file">so</a> $<a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a>]} {
<a class="l" name="137" href="#137">137</a>                <b>dict</b> <b>set</b> <a href="/source/s?defs=so" class="intelliWindow-symbol" data-definition-place="undefined-in-file">so</a> $<a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a> $<a href="/source/s?defs=value" class="intelliWindow-symbol" data-definition-place="undefined-in-file">value</a>
<a class="l" name="138" href="#138">138</a>            } <b>else</b> {
<a class="l" name="139" href="#139">139</a>                <b>error</b> <span class="s">&quot;unknown option for output format\
<a class="hl" name="140" href="#140">140</a>                        \&quot;$<a href="/source/s?defs=formatName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">formatName</a>\&quot;:\ \&quot;$<a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a>\&quot;&quot;</span>
<a class="l" name="141" href="#141">141</a>            }
<a class="l" name="142" href="#142">142</a>        }
<a class="l" name="143" href="#143">143</a>        <b>return</b> [${<a href="/source/s?defs=ns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ns</a>}<a href="/source/s?defs=%5C%3A%5C%3Aserialize" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::serialize</a> $<a href="/source/s?defs=data" class="intelliWindow-symbol" data-definition-place="undefined-in-file">data</a> $<a href="/source/s?defs=so" class="intelliWindow-symbol" data-definition-place="undefined-in-file">so</a>]
<a class="l" name="144" href="#144">144</a>    }
<a class="l" name="145" href="#145">145</a>
<a class="l" name="146" href="#146">146</a>    <span class="c"># Read data from a file or a channel into a new database table. The filename</span>
<a class="l" name="147" href="#147">147</a>    <span class="c"># or channel to read from and the options for how to read and store the data</span>
<a class="l" name="148" href="#148">148</a>    <span class="c"># are in all set in the dictionary $fileOptions.</span>
<a class="l" name="149" href="#149">149</a>    <a href="/source/s?defs=method" class="intelliWindow-symbol" data-definition-place="undefined-in-file">method</a> <a href="/source/s?defs=read%5C-file" class="intelliWindow-symbol" data-definition-place="undefined-in-file">read-file</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> {
<a class="hl" name="150" href="#150">150</a>        <span class="c"># Set the default table name (&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, ..., &quot;z&quot;).</span>
<a class="l" name="151" href="#151">151</a>        <b>set</b> <a href="/source/s?defs=defaultTableName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">defaultTableName</a> [<b>lindex</b> $<a href="/source/s?defs=defaultTableNames" class="intelliWindow-symbol" data-definition-place="undefined-in-file">defaultTableNames</a> [<b>dict</b> <a href="/source/s?defs=size" class="intelliWindow-symbol" data-definition-place="undefined-in-file">size</a> $<a href="/source/s?defs=tables" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tables</a>]]
<a class="l" name="152" href="#152">152</a>        <span class="c"># Set the default column name prefix equal to the table name.</span>
<a class="l" name="153" href="#153">153</a>        <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Adict%5C-ensure%5C-default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::dict-ensure-default</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <a href="/source/s?defs=table" class="intelliWindow-symbol" data-definition-place="undefined-in-file">table</a> $<a href="/source/s?defs=defaultTableName" class="intelliWindow-symbol" data-definition-place="undefined-in-file">defaultTableName</a>
<a class="l" name="154" href="#154">154</a>        <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Adict%5C-ensure%5C-default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::dict-ensure-default</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <a href="/source/s?defs=F0" class="intelliWindow-symbol" data-definition-place="undefined-in-file">F0</a> <span class="n">1</span>
<a class="l" name="155" href="#155">155</a>        <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Adict%5C-ensure%5C-default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::dict-ensure-default</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <a href="/source/s?defs=csvquote" class="intelliWindow-symbol" data-definition-place="undefined-in-file">csvquote</a> \&quot;
<a class="l" name="156" href="#156">156</a>        <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Adict%5C-ensure%5C-default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::dict-ensure-default</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <a href="/source/s?defs=csvsep" class="intelliWindow-symbol" data-definition-place="undefined-in-file">csvsep</a> ,
<a class="l" name="157" href="#157">157</a>        <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Adict%5C-ensure%5C-default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::dict-ensure-default</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <b>format</b> <a href="/source/s?defs=awk" class="intelliWindow-symbol" data-definition-place="undefined-in-file">awk</a>
<a class="l" name="158" href="#158">158</a>        <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Adict%5C-ensure%5C-default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::dict-ensure-default</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <a href="/source/s?defs=merge" class="intelliWindow-symbol" data-definition-place="undefined-in-file">merge</a> {}
<a class="l" name="159" href="#159">159</a>        <a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Adict%5C-ensure%5C-default" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::dict-ensure-default</a> <a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <a href="/source/s?defs=prefix" class="intelliWindow-symbol" data-definition-place="undefined-in-file">prefix</a> \
<a class="hl" name="160" href="#160">160</a>                [<b>dict</b> <a href="/source/s?defs=get" class="intelliWindow-symbol" data-definition-place="undefined-in-file">get</a> $<a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a> <a href="/source/s?defs=table" class="intelliWindow-symbol" data-definition-place="undefined-in-file">table</a>]
<a class="l" name="161" href="#161">161</a>
<a class="l" name="162" href="#162">162</a>        <b>array</b> <b>set</b> <a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a> $<a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a>
<a class="l" name="163" href="#163">163</a>
<a class="l" name="164" href="#164">164</a>        <span class="c"># Read the data.</span>
<a class="l" name="165" href="#165">165</a>        <b>if</b> {[<b>info</b> <a href="/source/s?defs=exists" class="intelliWindow-symbol" data-definition-place="undefined-in-file">exists</a> <a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=channel" class="intelliWindow-symbol" data-definition-place="undefined-in-file">channel</a>)]} {
<a class="l" name="166" href="#166">166</a>            <b>set</b> <a href="/source/s?defs=ch" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ch</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=channel" class="intelliWindow-symbol" data-definition-place="undefined-in-file">channel</a>)
<a class="l" name="167" href="#167">167</a>        } <b>elseif</b> {$<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<b>filename</b>) <a href="/source/s?defs=eq" class="intelliWindow-symbol" data-definition-place="undefined-in-file">eq</a> <span class="s">&quot;-&quot;</span>} {
<a class="l" name="168" href="#168">168</a>            <b>set</b> <a href="/source/s?defs=ch" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ch</a> <a href="/source/s?defs=stdin" class="intelliWindow-symbol" data-definition-place="undefined-in-file">stdin</a>
<a class="l" name="169" href="#169">169</a>        } <b>else</b> {
<a class="hl" name="170" href="#170">170</a>            <b>set</b> <a href="/source/s?defs=ch" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ch</a> [<b>open</b> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<b>filename</b>)]
<a class="l" name="171" href="#171">171</a>        }
<a class="l" name="172" href="#172">172</a>        <b>set</b> <a href="/source/s?defs=raw" class="intelliWindow-symbol" data-definition-place="undefined-in-file">raw</a> [<b>read</b> $<a href="/source/s?defs=ch" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ch</a>]
<a class="l" name="173" href="#173">173</a>        <b>close</b> $<a href="/source/s?defs=ch" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ch</a>
<a class="l" name="174" href="#174">174</a>
<a class="l" name="175" href="#175">175</a>        <b>set</b> <a href="/source/s?defs=rows" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rows</a> [$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=Parse" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Parse</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<b>format</b>) $<a href="/source/s?defs=raw" class="intelliWindow-symbol" data-definition-place="undefined-in-file">raw</a> $<a href="/source/s?defs=fileOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">fileOptions</a>]
<a class="l" name="176" href="#176">176</a>        <b>unset</b> <a href="/source/s?defs=raw" class="intelliWindow-symbol" data-definition-place="undefined-in-file">raw</a>
<a class="l" name="177" href="#177">177</a>
<a class="l" name="178" href="#178">178</a>        <span class="c"># Create and configure a new table object.</span>
<a class="l" name="179" href="#179">179</a>        <b>set</b> <a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a> [<a href="/source/s?defs=%5C%3A%5C%3Asqawk%5C%3A%5C%3Atable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">::sqawk::table</a> <a href="/source/s?defs=create" class="intelliWindow-symbol" data-definition-place="undefined-in-file">create</a> <a href="/source/s?defs=%25AUTO%25" class="intelliWindow-symbol" data-definition-place="undefined-in-file">%AUTO%</a>]
<a class="hl" name="180" href="#180">180</a>        $<a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a> <a href="/source/s?defs=configure" class="intelliWindow-symbol" data-definition-place="undefined-in-file">configure</a> \
<a class="l" name="181" href="#181">181</a>                -<a href="/source/s?defs=database" class="intelliWindow-symbol" data-definition-place="undefined-in-file">database</a> [$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=cget" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cget</a> -<a href="/source/s?defs=database" class="intelliWindow-symbol" data-definition-place="undefined-in-file">database</a>] \
<a class="l" name="182" href="#182">182</a>                -<a href="/source/s?defs=dbtable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">dbtable</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=table" class="intelliWindow-symbol" data-definition-place="undefined-in-file">table</a>) \
<a class="l" name="183" href="#183">183</a>                -<a href="/source/s?defs=columnprefix" class="intelliWindow-symbol" data-definition-place="undefined-in-file">columnprefix</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=prefix" class="intelliWindow-symbol" data-definition-place="undefined-in-file">prefix</a>) \
<a class="l" name="184" href="#184">184</a>                -<a href="/source/s?defs=f0" class="intelliWindow-symbol" data-definition-place="undefined-in-file">f0</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=F0" class="intelliWindow-symbol" data-definition-place="undefined-in-file">F0</a>) \
<a class="l" name="185" href="#185">185</a>                -<a href="/source/s?defs=maxnf" class="intelliWindow-symbol" data-definition-place="undefined-in-file">maxnf</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=NF" class="intelliWindow-symbol" data-definition-place="undefined-in-file">NF</a>) \
<a class="l" name="186" href="#186">186</a>                -<a href="/source/s?defs=modenf" class="intelliWindow-symbol" data-definition-place="undefined-in-file">modenf</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=MNF" class="intelliWindow-symbol" data-definition-place="undefined-in-file">MNF</a>)
<a class="l" name="187" href="#187">187</a>        <span class="c"># Configure datatypes.</span>
<a class="l" name="188" href="#188">188</a>        <b>if</b> {[<b>info</b> <a href="/source/s?defs=exists" class="intelliWindow-symbol" data-definition-place="undefined-in-file">exists</a> <a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=datatypes" class="intelliWindow-symbol" data-definition-place="undefined-in-file">datatypes</a>)]} {
<a class="l" name="189" href="#189">189</a>            $<a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a> <a href="/source/s?defs=configure" class="intelliWindow-symbol" data-definition-place="undefined-in-file">configure</a> -<a href="/source/s?defs=datatypes" class="intelliWindow-symbol" data-definition-place="undefined-in-file">datatypes</a> [<b>split</b> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=datatypes" class="intelliWindow-symbol" data-definition-place="undefined-in-file">datatypes</a>) ,]
<a class="hl" name="190" href="#190">190</a>        }
<a class="l" name="191" href="#191">191</a>        <span class="c"># Configure column names.</span>
<a class="l" name="192" href="#192">192</a>        <b>set</b> <a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a> {}
<a class="l" name="193" href="#193">193</a>        <b>if</b> {[<b>info</b> <a href="/source/s?defs=exists" class="intelliWindow-symbol" data-definition-place="undefined-in-file">exists</a> <a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a>)] &amp;&amp; $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a>)} {
<a class="l" name="194" href="#194">194</a>            <span class="c"># Remove the header from $rows.</span>
<a class="l" name="195" href="#195">195</a>            <b>set</b> <a href="/source/s?defs=rows" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rows</a> [<b>lassign</b> $<a href="/source/s?defs=rows" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rows</a> <a href="/source/s?defs=headerF0" class="intelliWindow-symbol" data-definition-place="undefined-in-file">headerF0</a>]
<a class="l" name="196" href="#196">196</a>            <span class="c"># Strip the first field (<a href="/source/s?path=a0/">a0</a>/<a href="/source/s?path=a0/b0">b0</a>/...) from the header.</span>
<a class="l" name="197" href="#197">197</a>            <b>set</b> <a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a> [<b>lrange</b> $<a href="/source/s?defs=headerF0" class="intelliWindow-symbol" data-definition-place="undefined-in-file">headerF0</a> <span class="n">1</span> <a href="/source/s?defs=end" class="intelliWindow-symbol" data-definition-place="undefined-in-file">end</a>]
<a class="l" name="198" href="#198">198</a>        }
<a class="l" name="199" href="#199">199</a>        <span class="c"># Override the header with custom column names.</span>
<a class="hl" name="200" href="#200">200</a>        <b>if</b> {[<b>info</b> <a href="/source/s?defs=exists" class="intelliWindow-symbol" data-definition-place="undefined-in-file">exists</a> <a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=columns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">columns</a>)]} {
<a class="l" name="201" href="#201">201</a>            <b>set</b> <a href="/source/s?defs=customColumnNames" class="intelliWindow-symbol" data-definition-place="undefined-in-file">customColumnNames</a> [<b>split</b> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=columns" class="intelliWindow-symbol" data-definition-place="undefined-in-file">columns</a>) ,]
<a class="l" name="202" href="#202">202</a>            <b>set</b> <a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a> [<b>list</b> \
<a class="l" name="203" href="#203">203</a>                    {*}[<b>lrange</b> $<a href="/source/s?defs=customColumnNames" class="intelliWindow-symbol" data-definition-place="undefined-in-file">customColumnNames</a> \
<a class="l" name="204" href="#204">204</a>                            <span class="n">0</span> [<b>llength</b> $<a href="/source/s?defs=customColumnNames" class="intelliWindow-symbol" data-definition-place="undefined-in-file">customColumnNames</a>]-<span class="n">1</span>] \
<a class="l" name="205" href="#205">205</a>                    {*}[<b>lrange</b> $<a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a> \
<a class="l" name="206" href="#206">206</a>                            [<b>llength</b> $<a href="/source/s?defs=customColumnNames" class="intelliWindow-symbol" data-definition-place="undefined-in-file">customColumnNames</a>] <a href="/source/s?defs=end" class="intelliWindow-symbol" data-definition-place="undefined-in-file">end</a>]]
<a class="l" name="207" href="#207">207</a>        }
<a class="l" name="208" href="#208">208</a>        $<a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a> <a href="/source/s?defs=configure" class="intelliWindow-symbol" data-definition-place="undefined-in-file">configure</a> -<a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a> $<a href="/source/s?defs=header" class="intelliWindow-symbol" data-definition-place="undefined-in-file">header</a>
<a class="l" name="209" href="#209">209</a>
<a class="hl" name="210" href="#210">210</a>        $<a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a> <a href="/source/s?defs=initialize" class="intelliWindow-symbol" data-definition-place="undefined-in-file">initialize</a>
<a class="l" name="211" href="#211">211</a>
<a class="l" name="212" href="#212">212</a>        <span class="c"># Insert rows in the table.</span>
<a class="l" name="213" href="#213">213</a>        $<a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a> <a href="/source/s?defs=insert%5C-rows" class="intelliWindow-symbol" data-definition-place="undefined-in-file">insert-rows</a> $<a href="/source/s?defs=rows" class="intelliWindow-symbol" data-definition-place="undefined-in-file">rows</a>
<a class="l" name="214" href="#214">214</a>
<a class="l" name="215" href="#215">215</a>        <b>dict</b> <b>set</b> <a href="/source/s?defs=tables" class="intelliWindow-symbol" data-definition-place="undefined-in-file">tables</a> $<a href="/source/s?defs=metadata" class="intelliWindow-symbol" data-definition-place="undefined-in-file">metadata</a>(<a href="/source/s?defs=table" class="intelliWindow-symbol" data-definition-place="undefined-in-file">table</a>) $<a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a>
<a class="l" name="216" href="#216">216</a>        <b>return</b> $<a href="/source/s?defs=newTable" class="intelliWindow-symbol" data-definition-place="undefined-in-file">newTable</a>
<a class="l" name="217" href="#217">217</a>    }
<a class="l" name="218" href="#218">218</a>
<a class="l" name="219" href="#219">219</a>    <span class="c"># Perform query $query and output the result to $channel.</span>
<a class="hl" name="220" href="#220">220</a>    <a href="/source/s?defs=method" class="intelliWindow-symbol" data-definition-place="undefined-in-file">method</a> <a href="/source/s?defs=perform%5C-query" class="intelliWindow-symbol" data-definition-place="undefined-in-file">perform-query</a> {<a href="/source/s?defs=query" class="intelliWindow-symbol" data-definition-place="undefined-in-file">query</a> {<a href="/source/s?defs=channel" class="intelliWindow-symbol" data-definition-place="undefined-in-file">channel</a> <a href="/source/s?defs=stdout" class="intelliWindow-symbol" data-definition-place="undefined-in-file">stdout</a>}} {
<a class="l" name="221" href="#221">221</a>        <span class="c"># For each row returned...</span>
<a class="l" name="222" href="#222">222</a>        <b>set</b> <a href="/source/s?defs=outputRecords" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputRecords</a> {}
<a class="l" name="223" href="#223">223</a>        [$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=cget" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cget</a> -<a href="/source/s?defs=database" class="intelliWindow-symbol" data-definition-place="undefined-in-file">database</a>] <b>eval</b> $<a href="/source/s?defs=query" class="intelliWindow-symbol" data-definition-place="undefined-in-file">query</a> <a href="/source/s?defs=results" class="intelliWindow-symbol" data-definition-place="undefined-in-file">results</a> {
<a class="l" name="224" href="#224">224</a>            <b>set</b> <a href="/source/s?defs=outputRecord" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputRecord</a> {}
<a class="l" name="225" href="#225">225</a>            <b>set</b> <a href="/source/s?defs=keys" class="intelliWindow-symbol" data-definition-place="undefined-in-file">keys</a> $<a href="/source/s?defs=results" class="intelliWindow-symbol" data-definition-place="undefined-in-file">results</a>(*)
<a class="l" name="226" href="#226">226</a>            <b>foreach</b> <a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a> $<a href="/source/s?defs=keys" class="intelliWindow-symbol" data-definition-place="undefined-in-file">keys</a> {
<a class="l" name="227" href="#227">227</a>                <b>lappend</b> <a href="/source/s?defs=outputRecord" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputRecord</a> $<a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a> $<a href="/source/s?defs=results" class="intelliWindow-symbol" data-definition-place="undefined-in-file">results</a>($<a href="/source/s?defs=key" class="intelliWindow-symbol" data-definition-place="undefined-in-file">key</a>)
<a class="l" name="228" href="#228">228</a>            }
<a class="l" name="229" href="#229">229</a>            <b>lappend</b> <a href="/source/s?defs=outputRecords" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputRecords</a> $<a href="/source/s?defs=outputRecord" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputRecord</a>
<a class="hl" name="230" href="#230">230</a>        }
<a class="l" name="231" href="#231">231</a>        <b>set</b> <a href="/source/s?defs=sqawkOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">sqawkOptions</a> {}
<a class="l" name="232" href="#232">232</a>        <b>foreach</b> <b>option</b> [$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <b>info</b> <b>options</b>] {
<a class="l" name="233" href="#233">233</a>            <b>dict</b> <b>set</b> <a href="/source/s?defs=sqawkOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">sqawkOptions</a> $<b>option</b> [$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=cget" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cget</a> $<b>option</b>]
<a class="l" name="234" href="#234">234</a>        }
<a class="l" name="235" href="#235">235</a>        <b>set</b> <a href="/source/s?defs=output" class="intelliWindow-symbol" data-definition-place="undefined-in-file">output</a> [$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=Serialize" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Serialize</a> [$<a href="/source/s?defs=self" class="intelliWindow-symbol" data-definition-place="undefined-in-file">self</a> <a href="/source/s?defs=cget" class="intelliWindow-symbol" data-definition-place="undefined-in-file">cget</a> -<a href="/source/s?defs=outputformat" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputformat</a>] $<a href="/source/s?defs=outputRecords" class="intelliWindow-symbol" data-definition-place="undefined-in-file">outputRecords</a> \
<a class="l" name="236" href="#236">236</a>                $<a href="/source/s?defs=sqawkOptions" class="intelliWindow-symbol" data-definition-place="undefined-in-file">sqawkOptions</a>]
<a class="l" name="237" href="#237">237</a>        <b>puts</b> -<a href="/source/s?defs=nonewline" class="intelliWindow-symbol" data-definition-place="undefined-in-file">nonewline</a> $<a href="/source/s?defs=channel" class="intelliWindow-symbol" data-definition-place="undefined-in-file">channel</a> $<a href="/source/s?defs=output" class="intelliWindow-symbol" data-definition-place="undefined-in-file">output</a>
<a class="l" name="238" href="#238">238</a>    }
<a class="l" name="239" href="#239">239</a>}
<a class="hl" name="240" href="#240">240</a></body>
</html>
